package com.hx.petsever.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.hx.petsever.entity.Vip;
import com.hx.petsever.mapper.VipMapper;
import com.hx.petsever.service.VipService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.HashMap;

@Service
public class VipServiceImpl extends ServiceImpl<VipMapper, Vip> implements VipService {

    @Autowired
    VipMapper vipMapper;

    @Override
    public HashMap toVip(String userid, Integer vip, Integer account) {
        HashMap<String, Object> map = new HashMap<>();
        Vip vip1 = vipMapper.havaVip(userid);

        if(vip1 != null)
        {
            map.put("state","0");
            map.put("msg","该用户已是会员");
        }else{
            vipMapper.insertvip(userid,vip,account);
            map.put("state","1");
            map.put("msg","恭喜你成为会员");
            vip1 = vipMapper.havaVip(userid);
        }
        map.put("data",vip1);
        return map;
    }
}
